
<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>余额提现</title>
		<link rel="stylesheet" href="__AGENT__/css/css.css" />
		<script type="text/javascript" src="__PUBLIC__/static/js/jquery.min.js"></script>
		<link rel="stylesheet" href="__PUBLIC__/static/layui/css/layui.css">
		<script src="__PUBLIC__/static/layui/layui.all.js"></script>
	</head>

	<body>
		<form class="layui-form update_form" action="">
			<div class="layui-form-item">
				<label class="layui-form-label">账号余额</label>
				<div class="layui-input-block update_shurk">
					<input type="text" id='agent_balance' value="{$agent_info['balance']}" name="" placeholder="{$agent_info['balance']}" class="layui-input" disabled="disabled">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">提现金额</label>
				<div class="layui-input-block update_shurk">
					<input type="text" id="tixian_money" name="tixian_money" required lay-verify="required" placeholder="￥" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div style="margin-left: 10%; margin-bottom: 10px;">商家签约绑定结算银行卡后，D+1进行结算，结算费率为0；申请成功后，该笔提现会在第二个工作日24:00点之前到账。</div>
			<div class="layui-form-item update_btnbox">
				<div class="layui-input-block">
					<button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
		<script>
			$(function(){
				var  is_qianyue = "{$agent_info['is_state']}";
				//检查商家是否已签约
				if(is_qianyue != 1){
					layer.msg('您还未完成签约',function(){
						parent.location.href = 'qianyue.html';
					})
				}
			})
			//Demo
			layui.use('form', function() {
				var form = layui.form;

				//监听提交
				form.on('submit(formDemo)', function(data) {
					var ex_num=$("#tixian_money").val();
					var agent_balance=$("#agent_balance").val();
					if(ex_num==""||isNaN(ex_num)||parseFloat(ex_num)<=0){
						layer.msg("请输入正确的提现金额");
						return false;
					}
					if(ex_num<95){
						layer.msg("单次提现金额不能小于95元");
						return false;
					}
					
					if(agent_balance < ex_num){
						layer.msg("余额不足");
						return false;
					}
					
					
					$.ajax({
			             	type:"post",
			                url:"{:url('index/yue_tixian')}",
			                data: $('.layui-form').serialize(),//表单数据
			                success:function(data){
			                    if(data.code==200){
			                    	layer.msg('成功', {
									  icon: 1,
									  time: 1500 //2秒关闭（如果不配置，默认是3秒）
									}, function(){
										window.parent.location.reload();
										var index = parent.layer.getFrameIndex(window.name); //获取窗口索引  
								       	parent.layer.close(index); 
									});
			                    }else{
			                    	layer.msg('失败！');//保存成功提示
			                    }
			                },error:function(data){
			                	var a = data;
			                }
					     });
					return false;
				});
			});
		</script>
	</body>

</html>